/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>		    All right reserved. 		     </p>
 * <p>项目名称 ： 	 深圳公路信息资源整合及国省检日常化监管管理        </p>
 * <p>创建者   :	詹春贤 
 * <p>描   述  :   应急保通-应急演练数据管理的控制器  </p>
 * <p>最后修改 : $: 2017年8月29日-下午1:39:20 v 1.0.0	 Administrator   $ </p>
 * 
*/

package com.pengtu.gsj.controller.lwfw;

import javax.servlet.http.HttpServletRequest;




import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pengtu.gsj.controller.base.DefaultBaseController;
import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.entity.lwfw.EmergDrill;
import com.pengtu.gsj.interceptor.Token;
import com.pengtu.gsj.service.lwfw.EmergDrillService;

/**
 * 
 * emergDrillController
 * 
 * 2017年8月29日 下午1:39:20
 * 
 * @version 1.0.0
 * 
 */

@Controller
@RequestMapping("emergDrill")
public class EmergDrillController extends DefaultBaseController{

	@Autowired
	private EmergDrillService emergDrillService;

	/**
	 * 加载
	 * @param id
	 * @return
	 */
	@ModelAttribute
	public EmergDrill load(String id){
		EmergDrill emergDrill;
		if(StringUtils.isNotEmpty(id)){
			emergDrill = emergDrillService.getEmergDrillById(id);
		}else{
			emergDrill = new EmergDrill();
		}
		return emergDrill;
	}
	
	
	/**
	 * 页面跳转
	 * @return
	 */
	@Token(save = true)
	@RequestMapping("listInfo")
	public String showLisfInfo() {
		return "lwfw/emergDrill_list";
	}
	
	
	@ResponseBody
	@RequestMapping(value="list", produces = "application/json; charset=utf-8")
	public Page<EmergDrill> getEmergDrillList(Page<EmergDrill> page, HttpServletRequest request){
		QueryFilter queryFilter = QueryFilter.buildFromHttpRequest(request);
		if (!page.isOrderBySetted()) {
			page.setOrderBy("drillTime");
			page.setOrder(Page.ASC);
		}
		page = emergDrillService.findEmergDrill(page,queryFilter);
		return page;
	}
	
	/**
	 * saveEmergDrill:
	 * 适用: 保存应急保通的数据
	 * @param emergDrill
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody
	@Token(remove = true)
	@RequestMapping(value = "save", method=RequestMethod.POST)
	public boolean saveEmergDrill(@ModelAttribute EmergDrill emergDrill){
		emergDrillService.saveEmergDrill(emergDrill);
		return true;
	}
	
	
	/**
	 * showEmergDrill:
	 * 适用: 展示应急保通页面
	 * @param emergDrill
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody    
	@RequestMapping(value="show")
	public EmergDrill showEmergDrill (@ModelAttribute EmergDrill emergDrill){
		return emergDrill;
	}
	
	/**
	 * delateEmergDrill:
	 * 适用: 删除应急保通的数据
	 * @param emergDrill
	 * @return 
	 * @exception 
	 * @since  1.0.0
	*/
	@ResponseBody
	@RequestMapping(value="delete")
	public boolean delateEmergDrill(@ModelAttribute EmergDrill emergDrill){
		emergDrillService.delateEmergDrill(emergDrill);
		return true;
	}
}
